{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <div class="col-sm-12">

                </div>
                <!--操作框开始-->
                <div class="col-sm-12">
                    <div class="input-group" >
                        <button class="btn btn-primary" type="button" onclick="wk.href('{:url('userAdd')}');">
                            <i class="fa fa-plus"></i> 新增管理员
                        </button>
                    </div>
                </div>
                <!--操作框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>

                    <!--图片模板-->
                    <script type="text/html" id="imgTpl">
                        <img src="{{d.user_image}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"/>
                    </script>

                    <!--状态显示模板-->
                    <script type="text/html" id="user_status">
                        {{# if(d.user_status == 1){ }}
                        正常
                        {{# } }}
                        {{# if(d.user_status == 2){ }}
                        冻结
                        {{# } }}
                    </script>

                    <script type="text/html" id="user_private_rule">
                        {{# if(d.user_private_rule == 1){ }}
                        仓库管理员
                        {{# } }}
                        {{# if(d.user_private_rule == 2){ }}
                        审核员
                        {{# } }}
                        {{# if(d.user_private_rule == 3){ }}
                        工程师
                        {{# } }}
                    </script>

                    <!--操作模板-->
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.layer_show('详情','{:url('userDetail')}?user_id={{d.user_id}}')" class="btn btn-warning btn-xs m-r-xs" title="详情"><i class="fa fa-search">详情</i></a>
                        <a href="javascript:;" onclick="wk.href('{:url('userEdit')}?user_id={{d.user_id}}')" class="btn btn-primary btn-xs m-r-xs" title="编辑"><i class="fa fa-pencil">编辑</i></a>
                        {{# if(d.user_status == 1) { }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('userFreeze')}', '确定冻结？')" class="btn btn-warning btn-xs m-r-xs" title="冻结"><i class="fa fa-arrow-down">冻结</i></a>
                        {{# } }}
                        {{# if(d.user_status == 2) { }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('userUsing')}', '确定启用？')" class="btn btn-info btn-xs m-r-xs" title="启用"><i class="fa fa-arrow-up">启用</i></a>
                        {{# } }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('userDel')}')" class="btn btn-danger btn-xs m-r-xs" title="删除"><i class="fa fa-trash-o">删除</i></a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Privateuser/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
//                {type: 'checkbox', fixed: 'left',}
                {type:'numbers', width: 60, title: '序号'}
                , {field: 'user_username', width: '', title: '昵称', align: 'center'}
                , {field: 'user_phone', width: 120, title: '手机号', align: 'center'}
                , {field: 'user_real_name', width: 100, title: '真实姓名', align: 'center'}
                , {field: 'user_image', width: 80, title: '头像', align: 'center', templet: '#imgTpl'}
                , {field: 'user_status', width: 80, title: '状态', align: 'center', toolbar: '#user_status'}
                , {field: 'user_private_rule', width: 100, title: '角色', align: 'center', toolbar: '#user_private_rule'}
                , {field: 'user_time', width: 160, title: '创建时间', align: 'center'}
                , {fixed: 'right', width: 250, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.img-circle').viewer({
                    url: 'data-original'
                });
            }
        });

        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['user_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>